package com.websocket.Controller;

//import com.websocket.config.WebSocketServer.WebSocket;
import com.websocket.config.WebSocketServer.WebSocket;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.socket.TextMessage;

import java.io.IOException;

/**
 * @ClassName TestController
 * @Date 2021/6/30 0030 上午 10:56
 * @Author Administrator
 * @Description TODO
 * Version 1.0
 */
@Slf4j
@Component
@RabbitListener(queues = "emailInfo")
public class MQListener {
    @Autowired
    private WebSocket webSocket;
    @RabbitHandler
    public void Recive(String msg) throws IOException {
        System.err.println("emailInfo队列接收的消息为：" + msg);
        webSocket.sendMessageAll(msg);
        System.err.println("scoket发送成功消息为: "+ msg);
    }
}
